package com.hxc.web.controller.interest;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hxc.common.annotation.Log;
import com.hxc.common.core.controller.BaseController;
import com.hxc.common.core.domain.AjaxResult;
import com.hxc.common.enums.BusinessType;
import com.hxc.interest.domain.TNoticeRead;
import com.hxc.interest.service.ITNoticeReadService;
import com.hxc.common.utils.poi.ExcelUtil;
import com.hxc.common.core.page.TableDataInfo;

/**
 * 公告阅读记录Controller
 * 
 * @author hxc
 * @date 2021-08-16
 */
@RestController
@RequestMapping("/interest/notice/read")
public class TNoticeReadController extends BaseController
{
    @Autowired
    private ITNoticeReadService tNoticeReadService;

    /**
     * 查询公告阅读记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TNoticeRead tNoticeRead)
    {
        startPage();
        List<TNoticeRead> list = tNoticeReadService.selectTNoticeReadList(tNoticeRead);
        return getDataTable(list);
    }

    /**
     * 导出公告阅读记录列表
     */
    @Log(title = "公告阅读记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TNoticeRead tNoticeRead)
    {
        List<TNoticeRead> list = tNoticeReadService.selectTNoticeReadList(tNoticeRead);
        ExcelUtil<TNoticeRead> util = new ExcelUtil<TNoticeRead>(TNoticeRead.class);
        return util.exportExcel(list, "公告阅读记录数据");
    }

    /**
     * 获取公告阅读记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tNoticeReadService.selectTNoticeReadById(id));
    }

    /**
     * 新增公告阅读记录
     */
    @Log(title = "公告阅读记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TNoticeRead tNoticeRead)
    {
        return toAjax(tNoticeReadService.insertTNoticeRead(tNoticeRead));
    }

    /**
     * 修改公告阅读记录
     */
    @Log(title = "公告阅读记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TNoticeRead tNoticeRead)
    {
        return toAjax(tNoticeReadService.updateTNoticeRead(tNoticeRead));
    }

    /**
     * 删除公告阅读记录
     */
    @Log(title = "公告阅读记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tNoticeReadService.deleteTNoticeReadByIds(ids));
    }
}
